package com.cloudkinto.controller.board;


import com.cloudkinto.base.BaseController;
import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.service.board.JpBoardService;
import com.cloudkinto.service.board.JpBoardService;
import com.cloudkinto.service.headercontainer.HeaderContainerService;
import com.cloudkinto.service.tailtrucks.TailTrucksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhangyy
 * @since 2020-10-27
 */
@RestController
@Api(tags = "日本仓看板模块")
@RequestMapping("api/admin/jpBoard")
public class JpBoardController extends BaseController {

    @Autowired
    private JpBoardService JpBoardService;
    @Autowired
    private TailTrucksService tailTrucksService;

    @GetMapping("/init")
    @ApiOperation(value = "查询初始化", notes = "新增初始化")
    public SingleResult getInfo() {
        return JpBoardService.getInfo();
    }

    @GetMapping("/list")
    @ApiOperation(value = "查询", notes = "查询（分页）")
    public SingleResult list(HttpServletRequest request) {

        Map<String, String> map = new HashMap<>();
        String storageId = request.getParameter("storageId");
        String status = request.getParameter("status");
        String startDate = request.getParameter("startDate");
        String endDate = request.getParameter("endDate");
        map.put("storageId", storageId);
        map.put("status", status);
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        return SingleResult.success(tailTrucksService.getList(map));
    }

    @GetMapping("/getInfoByDate")
    @ApiOperation(value = "查看某一天的订单信息", notes = "新增初始化")
    public SingleResult getInfoByDate(@RequestParam String startDate, @RequestParam String endDate,@RequestParam String storageId) {
        return JpBoardService.getInfoByDate(startDate,endDate,storageId);
    }

    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "新增初始化")
    public SingleResult detail(@RequestParam Long id) {
        return JpBoardService.detail(id);
    }
}

